import axios from "axios";
import { defineStore } from "pinia";
import { ref } from "vue";

export const useChannelsStore = defineStore('channels', () => {
  // 声明数据
  const channelsList = ref([])

  // 声明操作数据的方法
  const getList = async () => {
    // 支持异步
    const { data: { data } } = await axios.get('http://geek.itheima.net/v1_0/channels')
    channelsList.value = data.channels
  }
  return {
    channelsList,
    getList
  }
},{
  persist:true
})
